from django.db import models
from system.project.models import Channel
from utils.models import CoreModel
from django.conf import settings

table_prefix = settings.TABLE_PREFIX  # 数据库表名前缀


# from libs.utils import get_week_day, match_date


class Task(CoreModel):
    title = models.TextField(verbose_name='标题')
    content = models.TextField(verbose_name='内容', null=True)
    version = models.CharField(max_length=32, verbose_name='版本号', null=True)
    type = models.CharField(max_length=32, verbose_name='类型')
    owner = models.CharField(max_length=32, verbose_name='操作人', null=True, default='')
    date_time = models.CharField(max_length=32, verbose_name='排期时间')
    date = models.DateField(verbose_name='日期')
    status_choice = [(0, '未完成'), (1, '已完成'), (2, '历史')]
    status = models.IntegerField(choices=status_choice, default=0)
    template = models.BooleanField(default=False)
    channel = models.ForeignKey(to=Channel, on_delete=models.CASCADE)
    project = models.CharField(max_length=36, verbose_name='项目')

    class Meta:
        db_table = table_prefix + 'task'
        verbose_name = '项目排期表'
        verbose_name_plural = verbose_name
